# -*- shell-script -*-

# 30device-tree - device-tree related rendering routines.

# This file is part of the Linux lsvpd package.

# (C) Copyright IBM Corp. 2003, 2004

# Maintained by Martin Schwenke <martins@au.ibm.com>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
# $Id: 30device-tree,v 1.1 2006/04/11 18:38:28 emunson Exp $

db_subdir_vars_hooks="${db_subdir_vars_hooks} db_set_subdir_vars_dt"
db_set_subdir_vars_dt

# Backward compatibility hack.
[ -d "$db_bus_dt_dir" ] || db_bus_dt_dir="$db_bus_dir"
[ -d "$db_bus_dt_dir" ] || db_bus_dt_dir="$db"

[ -f "${db_bus_dt_dir}/model" ] || return 0

######################################################################

if [ -f "${db_bus_dt_dir}/device_type" ] ; then
    device_tree_device_type=$(cat "${db_bus_dt_dir}/device_type")
fi

list_linux_vpd ()
{
    list_linux_vpd_basic "$db_bus_dt_dir"
}

get_model ()
{
    local f="${db_bus_dt_dir}/model" 
    if [ -f  "$f" ] ; then
	local t
	read t <"$f"
	echo "$t"
    else
	get_model_basic
    fi
}

get_serial ()
{
    local f="${db_bus_dt_dir}/system-id" 
    if [ -f  "$f" ] ; then
	local t
	read t <"$f"
	echo "$t"
    else
	get_serial_basic
    fi
}
